import shop from './shop.js';

const buildMappingDataset = (data, params) => {
    var result = [],
        keys = {},
        mapping = params.mapping;

    // 返过来
    for (let i in mapping) {
        keys[mapping[i]] = i;
    }

    if (params.returnType == 'array') {
        for (let i in data) {
            let item = {};
            for (let j in data[i]) {
                item[keys[j]] = data[i][j];
            }
            result.push(item);
        }
    } else if (params.returnType == 'object') {
        for (let j in data) {
            result[keys[j]] = data[j];
        }
    }

    return result;
};

export default {
    buildMappingDataset,
    shop
};
